<template>
  <div>
    <div id="containerpic">
      <div id="content">
        <h2><strong>欢迎使用项目申报系统</strong></h2>
        <div class="splitcontentleft">
          <div id="subcontent">
            <div class="small box">
              <table width="150" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="15%" valign="middle"><img src="../assets/images/username.jpg" width="61" height="17"
                                                       align="bottom"/></td>
                  <td width="15%" valign="middle"><input name="username" v-model="user.username" type="text"
                                                         size="7"/>
                  </td>
                </tr>
                <tr>
                  <td valign="middle"><img src="../assets/images/password.jpg" width="61" height="17"/></td>
                  <td valign="middle"><input name="password" v-model="user.password" type="password" size="7"/></td>
                </tr>
                <tr>
                  <td height="30" colspan="2" valign="bottom"><input type="button" @click="login()" value="登录"/>
                  </td>
                </tr>
              </table>
            </div>
          </div>
          <p>&nbsp;</p>

        </div>
      </div>

    </div>
    <div id="container">
      <div id="footer">
        <p><a href="http://www.ascenttech.com.cn/" target="_blank">版权所有：北京亚思晟商务科技有限公司
          &copy;2004-2008|京ICP备05005681</a>
        </p>
      </div>

    </div>
  </div>
</template>

<script>
export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: "login",
  data() {
    return {
      user: {
        username: '',
        password: ''
      },
    }
  },
  mounted() {
  },
  methods: {
    login() {
      console.log(1);
      var _this = this;
      this.$axios({
        url: 'http://localhost:8080/api/user/login',

        method: 'post',
        data: _this.user
      }).then((res) => {
        console.log(res);
        if (res.data.code == 200) {
          sessionStorage.setItem("userInfo", JSON.stringify(res.data.data.userInfo));
          if (res.data.data.gid == 1) {
            location.href = "./admin/admin_index.html";
          } else if (res.data.data.gid == 2) {
            this.$router.push('/declare/expert/index');
          } else {
            this.$router.push('declare/unit/index');
          }
        } else {
          alert("登录失败");
        }
      })
    }
  }
}
</script>

<style scoped>
@import '../assets/css/andreas08(blue).css';
</style>
